import curl.Curl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/11/24.
 */
public class MainFun {
    public static void main(String[] args){
        Thread thread = new Thread(new task());
        thread.start();
    }
}
class task implements Runnable{
    public void run() {
        Date now = new Date();
        String minutes = new SimpleDateFormat("mm").format(now);// 获得当前分钟数
        int sleeptime = (60-Integer.parseInt(minutes));
        if (Integer.parseInt(minutes)>20){
            System.err.println("第一次运行时间如果>hh:20:00，则下个小时再取数据"+"  睡眠"+sleeptime+"分钟");
            try {
                Thread.sleep((sleeptime)*60*1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        while (true){
            Map<String,String> paramMap = new HashMap<String, String>();
//        paramMap.put("city","西安");
            paramMap.put("token","5j1znBVAsnSf5xQyNQyq");
//        {"error":"Sorry，您这个小时内的API请求次数用完了，休息一下吧！"}
            String url = "http://www.pm25.in/api/querys/all_cities.json";
            Curl.get(url,paramMap);
        }
    }
}


